import Vue from 'vue'
import { formatCurrency, formatDate, formatTime } from '@/util'

Vue.filter('currency', (value, hasSymbol) => {
    return formatCurrency(value, hasSymbol)
})
Vue.filter('date', (value) => {
    return formatDate(value)
})
Vue.filter('dateTime', (value) => {
    return formatDate(value, true)
})
Vue.filter('time', (value) => {
    return formatTime(value)
})
Vue.filter('empty', (value) => {
    return value ? value : '未知'
})
Vue.filter('member', (idList = [], memberList = []) => {
    let nameList = idList.map(id => {
    let target = memberList.find(item => item.id === id)
    if (target) {
        return target.name
    } else {
        return null
    }
    })
    return nameList.filter(obj => obj !== null).join('、')
})